home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / AppleShare IP 6.3 SDK / ASIP User Authentication Module / Server UAM SDK / SampleCode / Kleartxt UAM / Kleartext UAM.c next >
Encoding:
C/C++ Source or Header  |  1999-11-01  |  2.0 KB  |  85 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Kleartxt UAM.h
  3.  
  4.     Contains:    Sample UAM that uses a cleartext password
  5.  
  6.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  7. */
  8.  
  9.  
  10. #include <types.h>
  11. #include <CodeFragments.h> 
  12. #include <string.h>
  13. #include "UAM.h"
  14. #include "OAMTypes.h"
  15.  
  16.  
  17. #pragma export on
  18.  
  19. unsigned long UAMVersion = 0;
  20. unsigned long UAMFlags = 0;
  21. unsigned char *UAMName = "\pKleartxt Passwrd";
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27. OAMStatus    UAMAuthenticate(SInt32 operation, SInt32 id,
  28.                 void* authState, SInt32 authStateSize, void* authData, SInt32 authDataSize,
  29.                 void* authStateOut, SInt32* authStateSizeOut, void* authDataOut, SInt32* authDataSizeOut)
  30. {
  31.     int status = kOAMErrAuthenticationError;
  32.     unsigned char password[8];
  33.     UInt32    size = 8;
  34.     char *pwptr = (char *)authData;
  35.     
  36.     *authStateSizeOut = 0;
  37.     *authDataSizeOut = 0;
  38.  
  39.     switch (operation) {
  40.         case kUAMAuthLogin:                // for login
  41.             DebugStr("\pIn UAMAuthenticate operation = kUAMAuthLogin");
  42.             // skip the username
  43.             pwptr += (unsigned char)*pwptr + 1;    // the username is a pascal string
  44.             
  45.             UAMGetAttributeID(id, kUser, kPasswordAttribute, password, &size);
  46.             if (memcmp(pwptr, password, 8) == 0)
  47.             {
  48.                 status = 0;
  49.             }
  50.             
  51.             break;
  52.         case kUAMAuthLoginContinue:        // for login
  53.             DebugStr("\pIn UAMAuthenticate operation = kUAMAuthLoginContinue");
  54.             break;
  55.         case kUAMAuthChangeKey:            // for change password
  56.             DebugStr("\pIn UAMAuthenticate operation = kUAMAuthChangeKey");
  57.             break;
  58.         case kUAMAuthChangeKeyContinue:    // for change password
  59.             DebugStr("\pIn UAMAuthenticate operation = kUAMAuthChangeKeyContinue");
  60.             break;
  61.         
  62.     }
  63.     return status;
  64. }
  65.  
  66. pascal OSErr UAMSetUP(const CFragInitBlock *theInitBlock){
  67.  
  68.         // put one time initalization stuff here (called when agent loads the UAM at boot)
  69.         DebugStr("\pIn the Setup routine");
  70.     return noErr;    
  71. }
  72.  
  73.  
  74. pascal    void    UAMCleanUP(void){
  75.         // put  cleanup stuff here (called when agent unloads the UAM at shutdown)
  76.         DebugStr("\pIn the Shutdown routine");
  77. }
  78.  
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82.  
  83.  
  84.  
  85.